package umt.cs.cs241.Assignment1.r_1_9;

import java.util.Random;

/*
 * Chris Hanshew
 * CS 241 Assignment 1
 * 9/9/08
 * R 1.9
 */

public class Driver_r_1_9 {
	
	public static void main(String[] args) {
		
		Random randomGen = new Random();
		
		int number = randomGen.nextInt(10000) + 1;
		
		if(isOdd(number)){
			System.out.println(number + " is odd.");
		}else{
			System.out.println(number + " is even.");
		}
		
		
	}
	
	/**
	 * Determine if an int value is odd by checking its right-most bit.
	 * 
	 * @param i - An int value.
	 * @return isOdd - Boolean of whether or not the number is idd
	 */
	public static boolean isOdd(int i){
		
		boolean isOdd = false;
		
		//Odd numbers will always have 1 as the right-most bit.
		if(Integer.lowestOneBit(i) == 1){
			isOdd = true;
		}else{
			isOdd = false;
		}
		
		return isOdd;
	}

}
